(match-end 0) old new))))))
(defun dired-unmark-all-files (mark &optional arg)
- "Remove a specific mark or any mark from every file.
+ "Remove a specific mark (or any mark) from every file.
+After this command, type the mark character to remove,
+or type RET to remove all marks.
With prefix arg, query for each marked file.
Type \\[help-command] at that time for help."
- (interactive "sRemove marks (RET means all): \nP")
- (let ((count 0)
- (re (if (zerop (length mark)) dired-re-mark
- (concat "^" (regexp-quote mark)))))
- (save-excursion
- (let (buffer-read-only case-fold-search query
- (help-form "\
+ (interactive "cRemove marks (RET means all): \nP")
+ (save-excursion
+ (let* ((count 0)
+ buffer-read-only case-fold-search query
+ (string (format "\n%c" mark))
+ (help-form "\
Type SPC or `y' to unmark one file, DEL or `n' to skip to next,
`!' to unmark all remaining files with no more questions."))
- (goto-char (point-min))
- (while (re-search-forward re nil t)
- (if (or (not arg)
- (dired-query 'query "Unmark file `%s'? "
- (dired-get-filename t)))
- (progn (delete-char -1) (insert " ") (setq count (1+ count))))
- (forward-line 1))))
- (message "%s" (format "Marks removed: %d %s" count mark))))
+ (goto-char (point-min))
+ (while (if (eq mark ?\r)
+ (re-search-forward dired-re-mark nil t)
+ (search-forward string nil t))
+ (if (or (not arg)
+ (dired-query 'query "Unmark file `%s'? "
+ (dired-get-filename t)))
+ (progn (subst-char-in-region (1- (point)) (point)
+ (preceding-char) ?\ )
+ (setq count (1+ count)))))
+ (message (if (= count 1) "1 mark removed"
+ "%d marks removed")
+ count))))
\f
;; Logging failures operating on files, and showing the results.